package com.dorm.cj.medium;

public class User {

    String name;

    ChartRoom chartRoom;

    public User(String name, ChartRoom chartRoom) {
        this.name = name;
        this.chartRoom = chartRoom;
        chartRoom.register(this);
    }

    public void sendMsg(String msg) {
        chartRoom.sendMsg(this, msg);
    }

    public void receiveMsg(User from, String msg) {
        System.out.println(this.name + "收到{" + from.name + "}的消息:" + msg);
    }
}
